import React, { Component } from 'react';
import EmployeeService from '../services/EmployeeService';

class ViewEmployeeComponent extends Component {

    constructor(props){
        super(props)
        this.state = {
            id:this.props.match.params.id,
            employee:{}
        }
    }

    componentDidMount() {
        EmployeeService.getEmployeeById(this.state.id).then( res => {
            this.setState({employee:res.data});
        });
    }


    render() {
        return (
            <div className="container">
                <div className="card col-md-6 offset-md-3">
                    <div className="row"><h1>view employee detail</h1></div>
                    <div className="card-body">
                        <div className="row">firstName:{this.state.employee.firstName}</div>
                        <div className="row">firstName:{this.state.employee.lastName}</div>
                        <div className="row">firstName:{this.state.employee.emailId}</div>
                    </div>
                </div>
            </div>
        );
    }
}

export default ViewEmployeeComponent;